z<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="layui/css/layui.css">
</head>
<body>
<table id="addressList" class="layui-hide"></table>
<script id="toolbar"  type="text/html">
     <div class="layui-inline">
     <div class="layui-input-inline" style="width:200px;height:38px;">
       <input type="text" name="likeEmpNo" id="likeEmpNo" required lay-verify="required" placeholder="请输入工号或姓名" class="layui-input">
     </div>
     <div class="layui-inline">
       <button class="layui-btn layui-btn-sm"  data-type="reload" id="search"><i class="layui-icon">&#xe615;</i>搜索</button>
     </div>  
    </div>
</script>
<script src="layui/layui.js"></script>
<script th:inline="none">
  layui.use('table',function(){
	  var table=layui.table;
	  var $=layui.jquery;
	  table.render({
		  elem:'#addressList',
		  url:'/getAddressList',
		  toolbar:'#toolbar',
		  method:'post',
		  cols:[[
			  {field:'id',width:80,title:'ID'}
			  ,{field:'empNo',title:'员工号'}
			  ,{field:'name',title:'姓名'}
			  ,{field:'position',title:'职位'}
			  ,{field:'phone',title:'电话号码'}
		  ]],
		  id:'reload',
		  page:true
	  });
	  
	  //表格数据重载
	  var active={
			  reload:function(){
				  var likeEmpNo=$('#likeEmpNo');
				 // var likeDate=$('#likeDate');
				  table.reload('reload',{
					  page:{
						  curr:1
					  },
					  where:{
						  //参数name的名称要与控制器中的一致
						  likeEmpNo:likeEmpNo.val(),
						  //likeDate:likeDate.val(),
					  },
					  url:'/searchAddressList',
					  method:'post'
				  });
			  }
	  };
	  
	  //搜索按钮事件
	  
	  $("#search").on('click',function(){
		  var type=$(this).data('type');
		  active[type]?active[type].call(this):'';
	  });
  });
</script>
</body>
</html>